import ContainerManager from '@/components/ContainerManager';
import { listComposes } from '@/services/container/ContainerManagerController';
import { PageContainer } from '@ant-design/pro-components';
import React, { useEffect, useState } from 'react';

const AppPage: React.FC = () => {
  const [composes, setComposes] = useState<API.DockerComposeVO[]>([]);
  const [loading, setLoading] = useState<boolean>(true);

  useEffect(() => {
    const fetchData = async () => {
      const result = await listComposes('app');
      if (result.success) {
        setComposes(result.data || []);
      }
      setLoading(false);
    };

    fetchData();
  }, []);

  return (
    <PageContainer ghost header={{ title: '业务应用' }}>
      <ContainerManager
        composes={composes}
        loading={loading}
        type="app"
      />
    </PageContainer>
  );
};

export default AppPage;
